<div class="container reg-page">
    <div class="col-md-12">
        <div class="tab">
            <div class="tab-pane gray" >
            	<a href="javascript:void(0);" style="color:#c7c7c7;">
	                <i class="border-top gray"></i>
	                <!--
	                <i class="reg-spt icoblack"></i>
	                 -->
	               	 买家注册
                </a>
            </div>
			<div class="tab-pane" data-click="false">
				<a href="javascript:void(0);" style="color:#ff5991;">
                	<i class="border-top "></i>
                	<!--
                	<i class="reg-spt mob"></i>
                	 -->
					商家注册
				</a>
            </div>
        </div>
        <div class="tab-content">
            <div class="pull-left reg-box">
                <?php
                $form = $this->beginWidget('CActiveForm', array(
                    'id' => 'reg-mobile-form',
                ));
                ?>
                 <?php echo $form->errorSummary($model); ?>
                <table>
                    <tr>
                        <td class="title">手机号码:</td>
                        <td>
                            <?php echo $form->textField($model, 'username', array('placeholder' => "请输入您的手机",'class'=>'input')); ?>
                        </td>
                    </tr>
<!--                     <tr>
                        <td class="title">验证码:</td>
                        <td >
                             <input name="snscode" style="width:50px;float:left;" id="phone" type="text" value="<?php echo $snscode;?>" class="input">
                             <input type="button" id="snscode" value="免费获取验证码" style="width:120px;height:35px;float:left;margin-left: 10px;" />
                             <div class="reg_help_img"><div class="reg_help">注册未收到验证码时，可先注册买家账户再进入会员中心，转为卖家账户！</div></div>
                             
                        </td>
                    </tr> -->
                    <tr>
                        <td class="title">邮箱:</td>
                        <td>
                            <?php echo $form->textField($model, 'email', array('placeholder' => "请输入您的邮箱",'class'=>'input')); ?>
                        </td>
                    </tr>
                    <tr>
                        <td class="title">旺旺:</td>
                        <td>
                            <input id="wangwang" class="input" type="text" name="MembersModel[wangwang]" placeholder="请输入您的旺旺" value="<?php echo $model->wangwang ?>">
                        </td>
                    </tr>
                    <!--
                    <tr>
                        <td class="title">类型:</td>
                        <td class="radios">
                            <?php echo $form->radioButtonList($model, 'kind',array('1'=>'买家类型','0'=>'商家类型'),array('class'=>'radio'));?>
                          
                        </td>
                    </tr>
                    -->
                    <tr>
                        <td class="title">密码:</td>
                        <td><?php echo $form->passwordField($model, 'password', array('placeholder' => "请输入密码",'class'=>'input'));?></td>
                    </tr>
                    <tr>
                        <td class="title">确认密码:</td>
                        <td><?php echo $form->passwordField($model, 'repassword', array('placeholder' => "请重复密码",'class'=>'input'));?></td>
                    </tr>
                    <tr>
                        <td></td>
                        <td><?php echo $form->checkBox($model, 'agreement', array('class'=>'checkbox'));?>我已经认真阅读并同意妈咪街的《用户注册协议》 </td>
                    </tr>
                    <tr>
                        <td></td>
                        <td><input type="submit" class="btn reg-spt " value=""></td>
                    </tr>
                </table>
                <?php $this->endWidget(); ?>
            </div>
            <div class="pull-left login-box">
                <p>已有妈咪街账号</p>
                <p><a href="<?php echo $this->createUrl('/user/login/login'); ?>">直接登录</a></p>
            </div>
            <div class="clearfix"></div>
        </div>    
        
    </div>
</div>

<?php include $this->getViewFile('//user/lib/choise'); ?>

<script type="text/javascript">

$('.tab-pane:not([data-click="false"])').click(function(){
	window.location.href = "<?php echo $this->createUrl('/user/user/register', array('choise'=>'1')); ?>";
});

//$(".b").click(function(){
//	  $(this).removeAttr("onclick");
//	  setTimeout(function(){
//	   $(".b").attr("onclick","test();");
//	   },3000)
//	  })


var wait = 60;	//60秒才能发送一次
if (getCookie("time") == null || getCookie("time") < 0){
	setCookie("time",wait,wait);
}else if(getCookie("time") != wait)
{
	timeRef();
}

//计时器
function time(o) {
	
		if(!o)
			var o = document.getElementById("snscode");
		
		if(getCookie("time") == wait){
			var moblie = $('#MembersModel_username').val();
			$.getJSON('<?php echo YzwController::U('Public/snscode') ?>',{moblie:moblie},function(data){
				if(data.status){
					
				}else{
					alert(data.info);
				}
			});
		}
	
		if (getCookie("time") == null || getCookie("time") <= 0) {
			o.removeAttribute("disabled");
			o.value="免费获取验证码";

		} else {

			timeRef();
			
		}
}
//刷新按钮
function timeRef(){
	if(!o)
		var o = document.getElementById("snscode");
	waittime = getCookie("time");
	o.setAttribute("disabled", true);
	o.value="重新发送(" + waittime + ")";
	waittime--;
	setCookie("time",waittime);
	setTimeout(function() {
		time(o)
	},
	1000)
}
//点击获取验证码
document.getElementById("snscode").onclick=function(){
	$('.reg_help').show();
	var moblie = $('#MembersModel_username').val();
	if(moblie == ''){
		alert('手机号不能为空！');
		return false;
	}
  	if(!(/^1[3|4|5|8|7][0-9]\d{8}$/.test(moblie))){ 
        alert("手机号码格式不正确");  
        return false; 
    }
  	setCookie("time",wait,wait);
	time(this);
}

//js设置Cookie
function setCookie(name,value,time)
{
    var exp = new Date();
    exp.setTime(exp.getTime() + time * 1000);
    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}
//js获取Cookie
function getCookie(name)
{
    var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
 
    if(arr=document.cookie.match(reg))
        return (arr[2]);
    else
        return null;
}
$('.reg_help_img, .reg_help').mouseover(function(){
	$('.reg_help').show();
});
$('.reg_help_img, .reg_help').mouseout(function(){
	$('.reg_help').hide();
});
</script>
